package com.oig.common.module;

import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.lang.NonNull;

import java.io.Serializable;
import java.util.List;


/**
 * 属性结构节点类
 * @param <T>
 */
@Schema
public class TreeNode<T> implements Comparable<TreeNode<T>>,Serializable {

	private static final long serialVersionUID = 1L;
	@Schema(description = "节点对象")
	private T node;			//节点对象
	@Schema(description = "排序")
	private int ordinal;	//排序
	@Schema(description = "下级")
	private List<TreeNode<T>> child;	//下级
	
	public T getNode() {
		return node;
	}
	public void setNode(T node) {
		this.node = node;
	}
	public List<TreeNode<T>> getChild() {
		return child;
	}

	public void setChild(List<TreeNode<T>> child) {
		this.child = child;
	}
	
	public int getOrdinal() {
		return ordinal;
	}
	public void setOrdinal(int ordinal) {
		this.ordinal = ordinal;
	}
	
	@Override
	public int compareTo(@NonNull TreeNode<T> arg) {
		return ordinal-arg.getOrdinal();
	}
	
	
}
